<?php


$configStr = file_get_contents("./config.json");
$config = json_decode($configStr,true);

$shell=$config['stopNodeJsCmd']??null;
if(!$shell){
	die("指令不存在");
}

$resultArr = runCmd($shell);
print_r($resultArr);




function runCmd($shell){
    $msgArr = [];
    //$shell = "gulp --gulpfile {$workDir}/gulpfile.js default --filename '{$dir}'";
    //$shell = "ls -la";
    exec($shell, $result, $status);
    $shell = "<font color='red'>$shell</font>";
    $msgArr[]= "<pre>";
    if( $status ){
        $msgArr[]= "shell命令{$shell}执行失败, 结果如下<hr>";
        $msgArr[]= $result ;
    } else {
        $msgArr[]= "shell命令{$shell}成功执行, 结果如下<hr>";
        $msgArr[]= $result ;
    }
    $msgArr[]= "</pre>";
    return $msgArr;
}


